*, / and % will
be performed before + or - in any expression. Brackets can be used to force a
different order of evaluation to this. Where division is performed between
two integers, the result will be an integer, with remainder discarded. Modulo
reduction is only meaningful between integers. If a program is ever required
to divide a number by zero, this will cause an error, usually causing the
program to crash. |
|
The mod (%) is
simply the remainder produced by dividing two integers. In the example shown
in the table above, if we treat 10
/ 6 as an integer divison, the
quotient is 1 (rather than 1.666) and the remainder is 4. Hence, the variable
remainder will get the value 4. |